import {
	getAesData
} from '@/common/api/api.js'
export default {
	methods: {
		onlineService() {
			let userInfo = this.$store.state.user.userInfo;
			let companyId = this.companyId == undefined ? '532465' : this.companyId;
			console.log(JSON.parse(JSON.stringify(userInfo)),'2-----')
			let metaData = `<xml>
				<uid><![CDATA[${userInfo.userId}]]></uid>
				<category><![CDATA[${userInfo.userLevelName}]]></category>
				<nickName><![CDATA[${userInfo.nickName}]]></nickName>
				<phone><![CDATA[${userInfo.mobile}]]></phone>
				<photo><![CDATA[${userInfo.userAvatarUrl}]]></photo>
			</xml>`
			getAesData(metaData).then(result => {
				if (result.code == 200) {
					// 返回来的是xml，固定位数截取下
					let aesInfo = result.data
					let url = ''
					// 平台
					if (companyId == '532465') {
						url = `https://www.echatsoft.com/visitor/mobile/chat.html?companyId=${companyId}&echatTag=yanchaoshuzi&metaData=${encodeURIComponent(aesInfo)}`
						uni.setStorageSync('chatUrl', url)
						uni.navigateTo({
							url: '/pages/webview/echat'
						})
					} else {
						// // 商户客服，商户客服需要增加platformSign参数，用SHA加密
						// getShaData(companyId).then(resData => {
						// 	url = `https://www.echatsoft.com/visitor/mobile/chat.html?companyId=${companyId}&platformSign=${resData.msg}&metaData=${encodeURIComponent(aesInfo)}`
						// 	uni.setStorageSync('chatUrl', url)
						// 	uni.navigateTo({
						// 		url: '/pages/webview/echat'
						// 	})
						// })
					}
					
				}
			})
		},
	}
}